"""
ASGI config for django_init_Project project.

It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/
"""

# import os
#
# from django.core.asgi import get_asgi_application
#
# os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_init_Project.settings')
#
# application = get_asgi_application()

import os
from django.core.asgi import get_asgi_application
from channels.routing import ProtocolTypeRouter, URLRouter
from django_init_Project import routing

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_init_Project.settings')

# 支持http和websocket
application = ProtocolTypeRouter({
    "http": get_asgi_application(),     # 自动找url.py，找视图函数  --> http
    "websocket": URLRouter(routing.websocket_urlpatterns)   # routing(urls)、consumers(views)
})


